package com.acme.bankapp.service.bank;

public class SavingAccount extends AbstractAccount {
    public SavingAccount(double balance) {
        super(balance);
    }

    public void withdraw(double x) throws NotEnoughFundsException {
        if (x > maximumAmountToWithdraw()) {
            throw new NotEnoughFundsException(getBalance(), maximumAmountToWithdraw());
        }
        if (getBalance() >= x) {
            setBalance(getBalance() - x);
        }
    }

    @Override
    public double maximumAmountToWithdraw() {
        return getBalance();
    }
}